# Commerce Server Code Generation and Nuget Packages

Code generation and Nuget packages for Commerce Server 10

## Prerequisites

- Windows Server 2008, SQL Server and other Commerce Server prereqs
- Commerce Server 10 (Just installed, don't worry about the configuration, we'll do that for you)
- Visual Studio 2012

## Deployment

- Open a Powershell prompt
- CD to (SolutionDir)\Deployment
- To configure Commerce Server 10 > Deploy-CSConfig 
- To unpackage the StoreFrontSite pup package > Deploy-UpPup 
- To wire up the site and Foundation service > Deploy-Base 

## Version

TBA

## Solution Structure

### Database (Solution Folder)
Contains a number of sub folder to house database scripts, XML imports, database security scripts and other data related items.

### Deployment (Solution Folder)
Deployment scripts, tools and configuration

### Nuget (Solution Folder)
A solution folder for the nuget packages created from this solution.  Running the CreateNugetPackage.ps1 will create the packages.

#### AllInOneDemo
(Not Complete) Nuget package that deploys all other packages in order to fully demo Commerce Server.  This package will deploy Foundation, Presentation, Pup and Code Generation in a project.

#### CodeGeneration
CommerceServer_CodeGeneration.nuspec is the configuration for the nuget package that will add the code generation pieces to a Web Application project.  It references the tt files from the MVCSample and the dll from the CodeGeneration project.

#### FoundationServerConfiguration
Package that deploys Foundation config and the FoundationService.svc

#### PresentationConfiguration 
Nuget spec file for package that modifies the web.config of a Web Application project in order to configured it to accesss Commerce Server in 3-tier mode.
web.config.transform is the configuration that is added to the web.config of the Web Application project.

#### TwoTierConfiguration
Nuget spec file and configuration for package that will configure a web project for using Commerce Server in 2-tier mode.

#### Unpup
(Not Complete) Packages that runs pup to unpack the SolutionStorefront.pup in init.

### Solution Items (Solution Folder)
README.md (This file!)
Test project configuration.

### CSCodeGeneration.csproj 
The project that houses the C# code employed by the code generation templates in order to get Commerce Server metadata, etc.
It is assumed that these helpers are going to be called from a T4 template running in Visual Studio

### CSCodeGenerationTest.csproj 
A test assembly used to exercise and demo the CSCodeGeneration.csproj. Relies on the Foundation service being correctly configured.  

### CSCodeGenrationConfigurationTest.csproj
A test assembly to test the helper that loads the configuration file from one app domain into another. 

### Foundation 
A web project to hold the Foundation.svc.  This service provides the Commerce Server connection for all of the sample sites as well as the test project.

### MVCSample
A MVC site used to house the T4 code generation templates.  In the Models folder you'll find a template called CommerceEntities that will generate typed CommerceEntity wrappers for each of the entities defined in the Commerce Server metadata system. 
In the RequestTemplates.tt in the RequestTemplates folder generates static helper methods for calling the RequestTemplates defined in the RequestTemplateDefinitions.xml of the Foundation service.
ControllerFactory.tt in the RequestTemplates folder generates a simple factory for accessing Commerce Server Contrib controllers.
RequestTemplateException.tt generates a custom exception which encapsulates a Service Adapter error collection which can be returned if something goes wrong when using the Request Template helper methods. 
Other T4 files are includes or child templates of the templates mentioned above.

We'll put some demo videos online soon. 

## Contributing 

Fork & Pull

## License

Licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php).

